﻿////////////////////////////////////////////////////////////////////////////////
//
var emptool = emptool || {};


////////////////////////////////////////////////////////////////////////////////
// emptool.cookie

emptool.cookie = {};

emptool.cookie.setCookie = function (cookieName, cookieValue, durationInDays) {
    var d, expires;
    d = new Date();
    d.setTime(d.getTime() + (durationInDays * 24 * 60 * 60 * 1000));
    expires = "expires=" + d.toUTCString();
    document.cookie = cookieName + "=" + cookieValue + "; " + expires;
}

emptool.cookie.getCookie = function (cookieName) {
    var name, cookieArray, i, cookieValue;

    name = cookieName + "=";

    cookieArray = document.cookie.split(';');

    for (i = 0; i < cookieArray.length; i++) {

        cookieValue = cookieArray[i];

        while (cookieValue.charAt(0) == ' ') {
            cookieValue = cookieValue.substring(1);
        }

        if (cookieValue.indexOf(name) == 0) {
            return cookieValue.substring(name.length, c.length);
        }
    }

    return "";
}


////////////////////////////////////////////////////////////////////////////////
// setup

(function ($) {
    "use strict";

    $(document).ready(function () {
        $("button.language-selector").click(function () {
            emptool.cookie.setCookie("SELECTED_LANGUAGE", this.value, 3);
            window.location.reload();
        });
    });

}(jQuery));
